import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-11-08
 * Time: 16:25
 * To BE A Better Person-2020-3-2
 */
@WebServlet("/TestDemo2")
public class TestDemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=utf-8");
        StringBuilder res= new StringBuilder();
        res.append(req.getProtocol());
        res.append("<br>");
        res.append(req.getMethod());
        res.append("<br>");
        res.append(req.getRequestURI());
        res.append("<br>");
        res.append(req.getRequestURI());
        res.append("<br>");
        res.append(req.getContextPath());
        res.append("<br>");
        res.append(req.getQueryString());
        res.append("<br>");
        res.append(req.getCharacterEncoding());
        res.append("<br>");
        Enumeration<String> headerNames=req.getHeaderNames();
        while(headerNames.hasMoreElements()){
            String headername= headerNames.nextElement();
            res.append(headername+" ");
            res.append(req.getHeader(headername));
            res.append("<br>");
        }
        resp.getWriter().write(res.toString());
    }
}
